package Year22_Month06.day23_剑Off3;

public class 乘积小于K的子数组 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        //和小于target的变化题吧
        int num = 1;//记录当前窗口内数字乘积
        int pre = 0;//滑动窗口起始位置
        int count = 0;//记录乘积小于k的子数组个数
        for (int i = 0; i < nums.length; i++) {
            num *= nums[i];
            while(num >= k){
                num /= nums[pre];
                pre++;
                if(pre >= i) continue;
            }
            count++;
        }
        return count;
    }
}
